import { defineStore } from 'pinia'
import { getNavigationRequest } from '@/api/public'
import { useScrollLock } from '@vueuse/core'
import cardListStore from '../CardList/index.js'
const isLock = useScrollLock(document.body)
const useNavigation = defineStore('useNavigation', {
  state: () => ({
    Navigation: [],
    HeaderData: [
      {
        id: 1,
        category: '首页',
        icon: 'fas fa-home',
        path: '/home'
      },
      {
        id: 2,
        category: '个人空间',
        icon: 'fas fa-user',
        path: '/my'
      },
      {
        id: 3,
        category: '登陆',
        icon: 'fas fa-sign-in-alt',
        path: '/profile'
      }
    ],
    showNavigation: false,
    currentIndex: 0,
    isLock: false,
    //PC端下的Navigation
    isOpenNavigation: false
  }),

  actions: {
    async getNavigationData() {
      const { data } = await getNavigationRequest()
      this.Navigation = data
    },
    changeDesktopNavigationStatus() {
      this.isOpenNavigation = !this.isOpenNavigation
      console.log(this.isOpenNavigation);
      
    },
    //移动端下的Navigation
    changeShowNavigationMaskDialog() {
      this.showNavigation = !this.showNavigation
      if (this.showNavigation) {
        isLock.value = true
      } else {
        isLock.value = false
      }
    },
    changeCurrentActiveIndex(index, id) {
      const useCardListStore = cardListStore()
      useCardListStore.getArticleByCategoryId(id)
      this.currentIndex = index
      this.showNavigation = false
      isLock.value = false
    }
  }
})

export default useNavigation
